package Anotation_Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class BookStore
{

	String name;
	String author;
	int price;

	@Book(title = "活着", author = "余华", price = 50)
	void method_demo01()
	{
	}

	public static void main(String[] args) throws NoSuchMethodException, ClassNotFoundException
	{
		Class cls = BookStore.class;
		Method methods1 = cls.getDeclaredMethod("method_demo01");
		String annotationName = "Anotation_Test.Book";
		//检测获取的方法对象是否有注解
		if(methods1.isAnnotationPresent((Class<Annotation>)Class.forName(annotationName)))
		{
			Book book = methods1.getAnnotation(Book.class);
			System.out.println(book.title());
			System.out.println(book.author());
			System.out.println(book.price());
		}
	}

}
